<section class="dataset-author">
  <header>
    <h2 class="dataset-author__header">
      Owners
    </h2>

    <p class="dataset-author__byline">
      Please add at least <strong>2</strong> owners.
    </p>
  </header>

  <table class="nacho-table nacho-table--bordered dataset-owner-table">
    <thead>
      <tr>
        <th class="dataset-author-column--extra-wide">
          LDAP Username
        </th>
        <th class="dataset-author-column--extra-wide">Full Name</th>
        <th class="dataset-author-column--narrow">ID Type</th>
        <th class="dataset-author-column--wide">
          Ownership Type

          <a
            rel="noopener"
            target="_blank"
            href="https://iwww.corp.linkedin.com/wiki/cf/display/DWH/Metadata+Acquisition#ProjectOverview-ownership">
            <sup>
              <span class="glyphicon glyphicon-question-sign"
                    title="Link to more information">
              </span>
            </sup>
          </a>
        </th>
        <th></th>
      </tr>
    </thead>

    <tbody>
      {{#each confirmedOwnersWithAvatars as |confirmedOwnerWithAvatar|}}
        {{dataset-author
          owner=confirmedOwnerWithAvatar
          ownerTypes=ownerTypes
          removeOwner=(action "removeOwner")
          confirmSuggestedOwner=(action "confirmSuggestedOwner")
          updateOwnerType=(action "updateOwnerType")
        }}
      {{/each}}
    </tbody>

    <tbody>
      <tr>
        <div class="dataset-owner-table__add-owner">
          {{#if isAddingOwner}}
            {{pwr-user-lookup didFindUser=(action "addOwner")}}
          {{else}}
            <button class="nacho-button nacho-button--tertiary dataset-owner-table__trigger" {{action (mut isAddingOwner) true}}>
              {{fa-icon "plus"}} Add an owner
            </button>
          {{/if}}
        </div>
      </tr>
    </tbody>
  </table>
</section>

<section class="dataset-author">
  {{datasets/owners/suggested-owners
    owners=systemGeneratedOwnersWithAvatars
    ownerTypes=ownerTypes
    commonOwners=commonOwners
    removeOwner=(action "removeOwner")
    confirmSuggestedOwner=(action  "confirmSuggestedOwner")
    updateOwnerType=(action "updateOwnerType")}}
</section>

<section class="action-bar">
  <div class="container action-bar__content">
    <button
      class="nacho-button nacho-button--large-inverse action-bar__item dataset-authors-save"
      disabled={{requiredMinNotConfirmed}}
      onclick={{perform saveOwners}}>

      {{#if saveOwners.isIdle}}
        Save
      {{else}}
        {{pendulum-ellipsis-animation}}
      {{/if}}

    </button>

    {{#if requiredMinNotConfirmed}}
      <div class="dataset-authors-save-error">
        <p>
          {{fa-icon "times-circle-o" class="dataset-authors-save-error__icon"}}
          {{#if (eq changedState 1)}}
            {{#if (eq ownersRequiredCount 2)}}
              Add at least 2 DataOwners.
            {{else}}
              Add at least {{ownersRequiredCount}} more DataOwner(s).
            {{/if}}
          {{else}}
            Please make changes to save.
          {{/if}}
        </p>
      </div>
    {{/if}}
  </div>
</section>